package com.qingcloud.adminbackend.pojo.product;

import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 产品指令信息字段
 */
@Data
public class SendCommandResult implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("数据网关IP")
    private String ip;

    @ApiModelProperty("网关端口")
    private String port;

    @ApiModelProperty("网关实例编号")
    private Integer instanceId;

    @ApiModelProperty("发送时间")
    private String sendTime;

    @ApiModelProperty("数据发送内容")
    private String sendContent;

    @ApiModelProperty("发送内容格式")
    private String format;

    @ApiModelProperty("发送结果")
    private String sendResult;

    @ApiModelProperty("解析结果")
    private List<ProductParseData> parseResult;

    public List<String> getResult() {
        List<String> list = new ArrayList<>();
        if (StrUtil.isNotBlank(this.ip)) {
            list.add("数据网关IP：" + this.ip);
        }
        if (StrUtil.isNotBlank(this.port)) {
            list.add("数据网关端口：" + this.port);
        }
        if (Objects.nonNull(this.instanceId)) {
            list.add("网关实例编号：" + this.instanceId);
        }
        list.add("");
        list.add("发送时间：" + this.sendTime);
        list.add("");
        list.add("发送格式：" + this.format);
        list.add("发送内容：" + this.sendContent);
        list.add("");
        list.add("发送结果：" + this.sendResult);
        return list;
    }

}
